home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / MPW / Miscellaneous / MPW p2c / p2cLibraries / PStrings.h < prev   
Encoding:
C/C++ Source or Header  |  1997-01-29  |  3.1 KB  |  99 lines  |  [TEXT/MPS ]

  1. /*---------------------------------------------------------------------------*
  2.  |                                                                           |
  3.  |                <<< PStrings.h - Pascal string routines >>>                |
  4.  |                                                                           |
  5.  *---------------------------------------------------------------------------*/
  6.  
  7. /* This file contains:
  8.  
  9. PStr_Length(s)                                    - length of Pascal string
  10. PStr_Set(destS, srcS)                        - assign one Pascal string to another
  11. PStr_Cmp(s1, s2)                                - Compare two Pascal strings
  12. PStr_Pos(sub, src)                            - Position from left of substring in source string
  13. PStr_Copy(dst, src, amount)            -    Copy src string chars to dst and form a string
  14. PStr_Insert(dst, ins, start)        - Insert a string into another
  15. PStr_Delete(dst, start, amount)    - Delete characters from a string
  16. PStr_Concat(dst, s1,...,NULL)        -    Concat arbitrary number of strings
  17.     
  18. */
  19.  
  20. #ifndef __PSTRINGS__
  21. #define __PSTRINGS__
  22.  
  23. #ifndef __TYPES__
  24. #include <Types.h>
  25. #endif
  26.  
  27. #ifndef __STRING__
  28. #include <String.h>
  29. #endif
  30.  
  31.  
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35.  
  36. #define PStr_Length(s) (*(unsigned char *)(s))
  37.  
  38. extern void PStr_Set(unsigned char *destS, unsigned char *srcS);
  39.     /*
  40.      Assigns value of second string to first.
  41.     */
  42.  
  43. extern short PStr_Cmp(unsigned char *s1, unsigned char *s2);
  44.     /*
  45.      Compares the contents of two Pascal strings and returns <0 if s1 < s2, 0 if
  46.      s1 == s2, and >0 if s1 > s2.
  47.     */
  48.  
  49.     
  50. extern short PStr_Pos(unsigned char *sub, unsigned char *src);
  51.     /*
  52.     Find the first occurrence of Pascal string sub in the Pascal string src and
  53.     return the index of the first occurrence.
  54.     */
  55.     
  56.  
  57. extern unsigned char *PStr_Copy(unsigned char *dst, unsigned char *src,
  58.                                                              int startPos, int amount);
  59.     /*
  60.     Copy amount characters (or up to the last character of the src Pascal string)
  61.     from the src Pascal string starting at startPos in src to the dst Pascal string
  62.     and return a pointer to the dst Pascal string.  It is up to the caller to make
  63.     sure enough space is reserved in the dst string.
  64.     */
  65.     
  66.  
  67. extern unsigned char *PStr_Insert(unsigned char *dst, unsigned char *ins,
  68.                                                                 int startPos);
  69.     /*
  70.      Insert the ins Pascal string into the dst string starting at position
  71.      startPos in the dst string.  The function returns original dst
  72.      Pascal string with the insert as its value.  It is up to the caller to make
  73.      sure enough space is reserved in the dst string for the insertion.
  74.     */
  75.  
  76.  
  77. extern unsigned char *PStr_Delete(unsigned char *dst, int startPos, int amount);
  78.     /*
  79.     Delete amount characters (or all remaining characters) from the Pascal string
  80.     starting at the character indicated by startPos.
  81.     */
  82.  
  83.  
  84. extern unsigned char *PStr_Concat(unsigned char *dst, unsigned char *src1, .../*, NULL*/);
  85.     /*
  86.     Concatenate all the Pascal strings specified in the argument list together
  87.     with the dst Pascal string and return a pointer to the dst string.  It is up
  88.     to the caller to make sure enough space is reserved in the dst string for all
  89.     the concatenations.    No check is made to see that the string length exceeds
  90.     255 characters.
  91.     */
  92.  
  93.  
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97.  
  98. #endif
  99.